package org.opens.receiver;

import cn.hutool.extra.spring.SpringUtil;
import lombok.Data;
import org.opens.constants.GlobalConstants;
import org.opens.listener.RedisListener;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 功能描述
 *
 * @author: zhangyuming
 * @date: 2023/7/10 14:29
 */
@Component
@Data
public class RedisReceiver {

    public void onMessage(Map<String, Object> params) {
        Object handlerName = params.get(GlobalConstants.HANDLER_NAME);
        RedisListener listener = SpringUtil.getBean(handlerName.toString(), RedisListener.class);
        if (listener != null) {
            listener.onMessage(params);
        }
    }

}
